import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../../public/repeat_fun.dart';
import '../../utils/storage.dart';
import '../../http/index.dart';

class SetUp extends StatefulWidget {
  SetUp({Key key}) : super(key: key);

  @override
  _SetUpState createState() => _SetUpState();
}

class _SetUpState extends State<SetUp> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      appBar: AppBar(
        leading: moveBack(context),
        centerTitle: true,
        elevation: 0,
        title: Text('设置'),
      ),
      body: MyOption(),
    );
  }
}

class MyOption extends StatefulWidget {
  MyOption({Key key}) : super(key: key);

  @override
  _MyOptionState createState() => _MyOptionState();
}

class _MyOptionState extends State<MyOption> {
  bool _switchSelected = true;
  @override
  Widget build(BuildContext context) {
    return Container(
      height: double.infinity,
      padding: EdgeInsets.fromLTRB(30.w, 0, 30.w, 0),
      child: ListView(
        shrinkWrap: true,
        children: [
          ListTile(
              contentPadding: EdgeInsets.all(0),
              title: Text("新消息通知"),
              trailing: Switch(
                value: _switchSelected,
                onChanged: (value) {
                  setState(() {
                    _switchSelected = value;
                  });
                },
              )),
          Divider(height: 2.0, color: Colors.grey),
          ListTile(
            contentPadding: EdgeInsets.all(0),
            title: Text("修改密码"),
            trailing: Icon(Icons.keyboard_arrow_right),
            onTap: () {
              print("修改密码");
            },
          ),
          Divider(height: 2.0, color: Colors.grey),
          ListTile(
            contentPadding: EdgeInsets.all(0),
            title: Text("清除缓存"),
            trailing: Icon(Icons.keyboard_arrow_right),
            onTap: () {
              print("清除缓存");
            },
          ),
          Divider(height: 2.0, color: Colors.grey),
          ListTile(
            contentPadding: EdgeInsets.all(0),
            title: Text("系统版本"),
            trailing: Text('V1.0'),
            onTap: () {
              print("系统版本");
            },
          ),
          Divider(height: 2.0, color: Colors.grey),
          ListTile(
            contentPadding: EdgeInsets.all(0),
            title: Text("隐私策略"),
            trailing: Icon(Icons.keyboard_arrow_right),
            onTap: () {
              print("隐私策略");
            },
          ),
          Divider(height: 2.0, color: Colors.grey),
          SizedBox(height: 113.h),
          SizedBox(
            width: 600.w,
            height: 90.h,
            child: RaisedButton(
              color: Color(0xff155EE0),
              shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.all(Radius.circular(22.0)),
              ),
              child: Text(
                "退出登录",
                style: TextStyle(
                  color: Colors.white,
                  fontSize: 34.sp,
                ),
              ),
              onPressed: () async {
                clear();
                Navigator.of(context).pushReplacementNamed('/login');
              },
            ),
          ),
        ],
      ),
    );
  }
}
